

<script>
	$(function(){
		$('#{{datagrid_id}}').datagrid({
		    	columns:[[
		
		
		{field:'accountid',title:'交易账户',width:120},
		{field:'loginname',title:'登录名',width:39},
		{field:'name',title:'姓名',width:39},
		{field:'identify',title:'身份证号',width:120},
		
		{field:'tradeTime',title:'交易时间',width:80},
		{field:'tradeAmount',title:'交易金额',width:39},
        {field:'tradeType',title:'交易类型',width:39},
        {field:'approver',title:'操作员',width:80},
        {field:'status',title:'交易状态',width:56},
        {field:'id',title:'操作选项',width:78,
            formatter:function(value,row,index){
                if (value[1] == 0){
				   return '<a onclick="javascript:return agree('+value[0]+');" href="#">同意申请</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return refuse('+value[0]+')" href="#">拒绝申请</a>';
			    }
			    else {
			       return '<a onclick="javascript:return success('+value[0]+');" href="#">返还现金</a>';
			       }
			}
			
		}
	]],
	toolbar:[{
		id:'',
		text:'提现审批',
		iconCls:'',
		handler:function(){
			
		}},'-','-'


	],
		    onLoadError: function() {
		    	$.jBox.tip('没有数据或根据搜索条件查不到相关数据', 'info');
		    	$("div.datagrid-body").css("height",0).find("table > tbody").empty();
		    	$("div.datagrid-view").css("height",'23px');
		    }
		});
		 $('#{{datagrid_id}}s').searchbox({

            width:300,  
            searcher:function(value,name){
            	var result = $('#{{datagrid_id}}').datagrid('reload', {
        			query_key: name,
        			query_value: value
        		});
            },
            menu:'#{{datagrid_id}}mm',  
            prompt:'请输入搜索条件'  
        });
	});
function agree(value){		
		var message = '确定要同意该账户提现吗？<br/>' ;
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
            	$.ajax({
                    type:'POST',
                    url:'/lottery/accounts/agree_application',
                    data: {id:value},
                    success:function(data,status){
                    	$.jBox.tip('审批通过', 'success');
                    	$('#{{datagrid_id}}').datagrid('reload');
                    },
                    error:function (req, status, error){
                    	$.jBox.tip('操作失败，请重试', 'error');
                    }
                });
            }
            return true;
        });
       	return false;
	}	
	
function refuse(value){		
		var message = '确定要拒绝该账户提现吗？<br/>' ;
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
			   $.jBox("get:/lottery/accounts/refuse/"+value,{
                   title: '拒绝理由',
                   width: 550,
                   height: 350,
                   top: '9%',
                   buttons: {},
                   loaded:function(){
 	              }
                });
            }
            return true;      
        });
       	return false;
	}
	
function success(value){		
		var message = '是否已经按照提现金额全额付款给了店主？<br/>' ;
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
            	$.ajax({
                    type:'POST',
                    url:'/lottery/accounts/succ',
                    data: {id:value},
                    success:function(data,status){
                    	$.jBox.tip('提现处理完毕', 'success');
                    	$('#{{datagrid_id}}').datagrid('reload');
                    },
                    error:function (req, status, error){
                    	$.jBox.tip('操作失败', 'error');
                    }
                });
            }
            return true;
        });
       	return false;
	}
</script>

    
<div style="padding:20px;overflow:hidden;" class="ajust_height">
<div style="padding-bottom:20px;overflow:hidden;">
		<input id="{{datagrid_id}}s"></input>
		<div id="{{datagrid_id}}mm" style="width:120px">
			<div name="account" iconCls="icon-ok">额度账号</div>
			<div name="loginname" iconCls="icon-ok">登录名</div>
			<div name="name" iconCls="icon-ok">姓名</div>
		</div>
	</div>
	<table id="{{datagrid_id}}"  striped="true" url="/lottery/accounts/withdraws"
		pagination="true" iconCls="icon-save" url="" fitColumns="true" singleSelect="false"
		rownumbers="true" pageSize="15"   pageList=" [5,10,15,20,25]">
	</table>
</div>












 



	

